package com.cwiyc.orderonlineback.controller;

import com.cwiyc.orderonlineback.common.Result;
import com.cwiyc.orderonlineback.entity.Order;
import com.cwiyc.orderonlineback.entity.Orderdetail;
import com.cwiyc.orderonlineback.entity.Orderoperate;
import com.cwiyc.orderonlineback.mapper.OrderMapper;
import com.cwiyc.orderonlineback.service.OrderServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping
public class OrderController {

    @Resource
    OrderMapper orderMapper;
    @Autowired
    OrderServiceImpl orderService;

    //创建订单
    @PostMapping("/createorder")
    public Result<?> createOrder(@RequestBody Order order) {
        return orderService.createOrder(order);
    }

    //订单内容
    @PostMapping("/createod")
    public Result<?> createOd(@RequestBody List<Orderdetail> orderdetails) {
        return orderService.createOd(orderdetails);
    }

    //商家获取订单
    @PostMapping("/getorderlist")
    public Result<?> getOrderlist(@RequestBody Integer uid) {
        return orderService.getOrderlist(uid);
    }

    @PostMapping("/getorderlistdetail")
    public Result<?> getOrderlistdetail(@RequestBody Integer uid) {
        return orderService.getOrderlistdetail(uid);
    }

    //顾客获取订单
    @PostMapping("/userorderlist")
    public Result<?> userOrderlist(@RequestBody Integer uid) {
        return orderService.userOrderlist(uid);
    }

    @PostMapping("/userorderlistdetail")
    public Result<?> userOrderlistdetail(@RequestBody Integer uid) {
        return orderService.userOrderlistdetail(uid);
    }

    @PostMapping("/operateorder")
    public Result<?> operateOrder(@RequestBody Orderoperate orderoperate) {
        return orderService.operateOrder(orderoperate);
    }
}
